
//
//  MerchantColorChoseView.m
//  BigJoy
//
//  Created by Rowling on 2017/7/13.
//  Copyright © 2017年 Rowling. All rights reserved.
//

#import "MerchantColorChoseView.h"
#import "CommonLableCollectionViewCell.h"

@interface MerchantColorChoseView ()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (nonatomic,strong) UICollectionView *collectionView;
@property (nonatomic,strong) UILabel *label;
@end
@implementation MerchantColorChoseView

-(UILabel *)label {
    if (_label == nil) {
        _label = [[UILabel alloc]init];
    }
    return _label;
}

-(UICollectionView *)collectionView {
    if (_collectionView == nil) {
        UICollectionViewFlowLayout * layout = [[UICollectionViewFlowLayout alloc]init];
        layout.minimumInteritemSpacing = XMH(10);
        layout.itemSize = CGSizeMake(64, 30);
        layout.sectionInset = UIEdgeInsetsMake(0, XMW(10), 0, XMW(10));
        layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(50, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 64) collectionViewLayout:layout];
        _collectionView.showsHorizontalScrollIndicator = NO;
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        _collectionView.backgroundColor = [UIColor whiteColor];
        [_collectionView registerNib:[UINib nibWithNibName:@"CommonLableCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"Cell"];
    }
    return _collectionView;
}

-(void)setCount:(NSInteger)count {
    _count = count;
    self.label.frame = CGRectMake(10, 0, 25, 12);
    self.label.font = [UIFont systemFontOfSize:13];
    self.label.textColor = [UIColor colorForHex:@"666666"];
    [self addSubview:self.label];
    [self addSubview:self.collectionView];
    [self.collectionView layoutSubviews];
    self.collectionView.height = self.collectionView.contentSize.height;
    self.height = self.collectionView.contentSize.height;
}



-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.count;
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    CommonLableCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
    return cell;
}

@end
